#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
int a[9];
int b[9]={}, c[17]={}, d[17]={};
int to = 0;
void print()
{
	cout << "<" << ++to << ">";
	for (int i = 1; i < 9; i++)
	{
		cout << a[i]<<" ";
	}cout << endl;
}
void dfs(int i)
{
	for (int j = 1; j < 9; j++)
	{
		if (!b[j] && !c[i + j] && !d[i - j + 7])
		{
			a[i] = j;
			b[j] = 1;
			c[i + j] = 1;
			d[i - j + 7] = 1;
			if (i == 8)print();
			else
			
				dfs(i + 1);
				b[j] = 0;
				c[i + j] = 0;
				d[i- j + 7] = 0;
			
		}
	}
}
int main()
{
	dfs(1);
	return 0;
}